home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
LANG
/
C
/
GCC
/
CLIB
/
!clib
/
h
/
kernel
< prev
next >
Wrap
Text File
|
1997-04-06
|
8KB
|
236 lines
/* kernel.h
For use with the GNU compilers and the SharedCLibrary.
(c) Copyright 1997, Nick Burrett. */
#ifndef __KERNEL_H
#define __KERNEL_H
#ifdef __cplusplus
extern "C" {
#endif
/* GCC has various useful declarations that can be made with the
__attribute__ syntax. Disable its use for other compilers. */
#ifndef __GNUC__
#ifndef __attribute__
#define __attribute__(x) /* Ignore. */
#endif
#endif
typedef struct
{
int errnum;
char errmess[252];
} _kernel_oserror;
/* Stack management functions. */
typedef struct stack_chunk
{
unsigned long sc_mark; /* == 0xf60690ff */
struct stack_chunk *sc_next, *sc_prev;
unsigned long sc_size;
int (*sc_deallocate)();
} _kernel_stack_chunk;
/* Return a pointer to the current stack chunk. */
extern _kernel_stack_chunk *_kernel_current_stack_chunk (void);
typedef struct
{
int r4, r5, r6, r7, r8, r9;
int fp, sp, pc, sl;
int f4[3], f5[3], f6[3], f7[3];
} _kernel_unwindblock;
/* Unwind the call stack one level. Return: >0 on success,
0 if stack end has been reached, <0 any other failures. */
extern int _kernel_unwind(_kernel_unwindblock *inout, char **language);
/* Program environment functions. */
/* Return a pointer to the name of the function that contains the
address 'pc' (or zero if no name can be found). */
extern char *_kernel_procname (int pc);
/* Return a pointer to the name of the language that the address
'pc' lies within. Zero if the language is unknown. */
extern char *_kernel_language (int pc);
/* Return a pointer to the command string used to run the program. */
extern char *_kernel_command_string (void);
/* Set the return code to be used by _kernel_exit. */
extern void _kernel_setreturncode (unsigned code);
/* Call OS_Exit. Use the return code set by _kernel_setreturncode. */
extern void _kernel_exit (int) __attribute__ ((__noreturn__));
/* Generates an external error. */
extern void _kernel_raise_error (_kernel_oserror *);
/* Reset the InTrapHandler flag to prevent recursive traps. */
extern void _kernel_exittraphandler (void);
/* Returns 6 for RISC OS. */
extern int _kernel_hostos (void);
/* Return non-zero if floating point instructions are available. */
extern int _kernel_fpavailable (void);
/* Return the last OS error since the last time _kernel_last_oserror
was called. Return zero if no errors have occurred. */
extern _kernel_oserror *_kernel_last_oserror (void);
/* Read the value of system variable 'name', placing the result in 'buffer'. */
extern _kernel_oserror *_kernel_getenv(const char *name, char *buffer, unsigned size);
/* Set the system variable 'name' with 'value'. If 'value == 0' then
'name' is deleted. */
extern _kernel_oserror *_kernel_setenv(const char *name, const char *value);
/* Return 1 if there has been an Escape since the previous call to
_kernel_escape_seen. */
extern int _kernel_escape_seen (void);
/* Enable IRQ interrupts. This can only be executed within SVC mode. */
extern void _kernel_irqs_on (void);
/* Disable IRQ interrupts. This can only be executed within SVC mode. */
extern void _kernel_irqs_off (void);
/* Return non-zero if IRQs are disabled. */
extern int _kernel_irqs_disabled (void);
/* General utility functions. */
typedef struct
{
int r[10];
} _kernel_swi_regs;
/* Call the SWI specified by 'no'. 'in' points to a register block for SWI entry.
'out' points to a register block for SWI exit. The X bit is set by _kernel_swi
unless bit 31 is set. */
extern _kernel_oserror *_kernel_swi (int no, _kernel_swi_regs *in,
_kernel_swi_regs *out);
/* Similar to _kernel_swi but the carry flag status is returned in 'carry'. */
extern _kernel_oserror *_kernel_swi_c (int no, _kernel_swi_regs *in,
_kernel_swi_regs *out, int *carry);
/* Perform an OS_Byte operation.
R1 is returned in the bottom byte, R2 in the second byte,
if carry set, then third byte = 1. */
extern int _kernel_osbyte (int op, int x, int y);
/* Read a character from the OS input stream. */
extern int _kernel_osrdch (void);
/* Write a character to the OS output streams. The return value indicates
success or failure. */
extern int _kernel_oswrch(int ch);
/* Return the next byte from the file 'handle'. Return -1 on EOF. */
extern int _kernel_osbget (unsigned handle);
/* Write the byte 'ch' to the file 'handle'. Return success or failure. */
extern int _kernel_osbput (int ch, unsigned handle);
typedef struct
{
void * dataptr;
int nbytes, fileptr;
int buf_len;
char *wild_fld;
} _kernel_osgbpb_block;
/* Read/write a number of bytes on file 'handle'. */
extern int _kernel_osgbpb (int op, unsigned handle, _kernel_osgbpb_block *inout);
/* Perform an OS_Word operation. */
extern int _kernel_osword (int op, int *data);
/* Open or close a file. Open returns a file handle, close just
indicates success/failure. */
extern int _kernel_osfind (int op, char *name);
typedef struct
{
int load, exec;
int start, end;
} _kernel_osfile_block;
/* Perform an OS_File operation. The _kernel_osfile_block provides
values for registers R2-R5. */
extern int _kernel_osfile (int op, const char *name, _kernel_osfile_block *inout);
/* Perform an OS_Args operation. Generally returns the value in R2, unless
op = 0. */
extern int _kernel_osargs (int op, unsigned handle, int arg);
/* Call OS_CLI with the string 's'. If another application is called,
the current application will be closed down. */
extern int _kernel_oscli (const char *s);
/* Call OS_CLI with the string 's'. If chain == 0, then the current
application is copied away and the new application executed as
a subprogram. Control will return to the main application once the
subprogram has completed.
If chain == 1, then _kernel_system will not return. */
extern int _kernel_system (const char *string, int chain);
/* Memory allocation functions. */
/* Tries to allocate a block of size 'words' words. If it fails,
it allocates the largest possible block. */
extern unsigned _kernel_alloc (unsigned words, void **block);
/* Register procedures to be used by the SharedCLibrary when it
creates to frees memory e.g. on creation of stack chunks. */
typedef void freeproc (void *);
typedef void *allocproc (unsigned);
extern void _kernel_register_allocs (allocproc *malloc, freeproc *free);
/* If the heap limit != application limit, then the procedure
registered here is used to request n bytes from the memory
allocation routine. */
typedef int _kernel_ExtendProc (int /* n */, void ** /* p */);
_kernel_ExtendProc *_kernel_register_slotextend (_kernel_ExtendProc *proc);
/* Language support. */
/* Unsigned divide and remainder function. Returns the remainder in R1. */
extern unsigned
_kernel_udiv (unsigned divisor, unsigned dividend) __attribute__ ((__const__));
/* Unsigned remainder function. */
extern unsigned
_kernel_urem (unsigned divisor, unsigned dividend) __attribute__ ((__const__));
/* Unsigned divide and remainder function by 10.
Returns the remainder in R1. */
extern unsigned _kernel_udiv10 (unsigned dividend) __attribute__ ((__const__));
/* Signed divide and remainder function. Returns the remainder in R1. */
extern int _kernel_sdiv (int divisor, int dividend) __attribute__ ((__const__));
/* Signed remainder function. */
extern int _kernel_srem (int divisor, int dividend) __attribute__ ((__const__));
/* Signed divide and remainder function by 10.
Returns the remainder in R1. */
extern int _kernel_sdiv10 (int dividend) __attribute__ ((__const__));
#ifdef __cplusplus
}
#endif
#endif